<table class="app-structure-diagram-table" *ngIf="!!node">
  <tr [ngClass]="sd.getAnimatedCls()">
    <td [attr.colspan]="node.children && node.children? node.children.length*2:0">
      <div class="app-structure-diagram-node-content">
        <div class="app-structure-diagram-node-name" (click)="sd.nodeClick(node)" [ngClass]="sd.drawCls(node)">
          <i nz-icon [nzType]="node.iconCls" nzTheme="outline" [hidden]="!node.iconCls"></i>
          {{node.text}}
        </div>
        <span class="app-structure-diagram-node-toggler" *ngIf="node.children && node.children.length">
          <i nz-icon [nzType]="node.state==='closed'?'down':'up'" nzTheme="outline" (click)="toggle($event, node)"></i>
        </span>
      </div>
    </td>
  </tr>

  <ng-container *ngIf="node.children && node.children.length">
    <tr class="app-structure-diagram-lines" [hidden]="node.state==='closed'? true : false">
      <td [attr.colspan]="node.children.length*2">
        <div class="app-structure-diagram-line-down"></div>
      </td>
    </tr>

    <tr class="app-structure-diagram-lines" [hidden]="node.state==='closed'? true : false">
      <ng-container *ngIf="node.children.length === 1">
        <td [attr.colspan]="node.children.length*2">
          <div class="app-structure-diagram-line-down"></div>
        </td>
      </ng-container>
      <ng-container *ngIf="node.children.length > 1">
        <ng-template ngFor let-child [ngForOf]="node.children" let-first="first" let-last="last">
          <td class="app-structure-diagram-line-left" [ngClass]="{'app-structure-diagram-line-top':!first}">&nbsp;</td>
          <td class="app-structure-diagram-line-right" [ngClass]="{'app-structure-diagram-line-top':!last}">&nbsp;</td>
        </ng-template>
      </ng-container>
    </tr>


    <tr class="app-structure-diagram-nodes" [hidden]="node.state==='closed'? true : false">
      <td colspan="2" *ngFor="let children of node.children">
        <app-structure-diagram-node [node]="children"></app-structure-diagram-node>
      </td>
    </tr>
  </ng-container>

</table>